Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Collections.​Generic.​PriorityQueue<​TElement, TPriority>

Assembly: System.Collections

Inheritance: object → PriorityQueue

Represents a collection of items that have a value and a priority. On dequeue, the item with the lowest priority value is removed.

Properties

public IComparer<​TPriority>
Comparer
Gets the priority comparer used by the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
public int
Count
Gets the number of elements contained in the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
public int
Capacity
Gets the total numbers of elements the queue's backing storage can hold without resizing.
public UnorderedItemsCollection<​TElement, TPriority>
UnorderedItems
Gets a collection that enumerates the elements of the queue in an unordered manner.

Methods

public void
Clear​()
Removes all items from the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
public TElement
Dequeue​()
Removes and returns the minimal element from the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> - that is, the element with the lowest priority value.
Returns The minimal element of the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
public TElement
DequeueEnqueue​(TElement element, TPriority priority)
Removes the minimal element and then immediately adds the specified element with associated priority to the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
Returns The minimal element removed before performing the enqueue operation.
element The element to add to the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
priority The priority with which to associate the new element.
public void
Enqueue​(TElement element, TPriority priority)
Adds the specified element with associated priority to the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
element The element to add to the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
priority The priority with which to associate the new element.
public TElement
EnqueueDequeue​(TElement element, TPriority priority)
Adds the specified element with associated priority to the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> , and immediately removes the minimal element, returning the result.
Returns The minimal element removed after the enqueue operation.
element The element to add to the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
priority The priority with which to associate the new element.
public void
EnqueueRange​(IEnumerable<​ValueTuple<​TElement, TPriority>> items)
Enqueues a sequence of element-priority pairs to the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
items The pairs of elements and priorities to add to the queue.
public void
EnqueueRange​(IEnumerable<​TElement> elements, TPriority priority)
Enqueues a sequence of elements pairs to the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> , all associated with the specified priority.
elements The elements to add to the queue.
priority The priority to associate with the new elements.
public int
EnsureCapacity​(int capacity)
Ensures that the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> can hold up to <paramref name="capacity" /> items without further expansion of its backing storage.
Returns The current capacity of the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
capacity The minimum capacity to be used.
public TElement
Peek​()
Returns the minimal element from the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> without removing it.
Returns The minimal element of the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> .
public bool
Remove​(TElement element, TElement& removedElement, TPriority& priority, IEqualityComparer?<​TElement> equalityComparer = null)
public void
TrimExcess​()
Sets the capacity to the actual number of items in the <see cref="T:System.Collections.Generic.PriorityQueue`2" /> , if that is less than 90 percent of current capacity.
public bool
TryDequeue​(TElement& element, TPriority& priority)
public bool
TryPeek​(TElement& element, TPriority& priority)
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object